package game.view.assignmentMenu
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.text.TextField;
	import game.UIComponent.Button;
	import game.UIComponent.Panel;
	import game.UIComponent.TabButton;
	import game.common.CustomBitmap;
	import game.common.Reflection;
	import game.managers.LanguageManager;
	import game.utils.Utils;
	
	public class Assignment extends Panel
	{
		private var _bar:CustomBitmap;
		private var _titleBg:CustomBitmap;
		private var _bg:CustomBitmap;
		private var _daily:TabButton;
		private var _greenborn:TabButton;
		private var _first:TaskType;
		private var _second:NewTaskType;
		
		
		public function Assignment()
		{
			init();
		}
		override protected function init():void
		{
			setBgImage("missionMainBg",550,450);
			setCenter();			
			close=new Point(500,-10);
						
			_titleBg=new CustomBitmap();
			_titleBg.source="titleBg";
			_titleBg.x=50;	
			_titleBg.y=30
			addChild(_titleBg);
			
			_daily=new TabButton(LanguageManager.getWord("task"),liuyanclickHandler,"missionTab");
			_daily.x=_titleBg.x;
			_daily.y=_titleBg.y+50;	
			_now=_daily;
			_daily.choose=true;
			addChild(_daily);
			
				
			_greenborn=new TabButton(LanguageManager.getWord("newtask"),liuyanclickHandler,"missionTab");
			_greenborn.x=_daily.x+_daily.width;
			_greenborn.y=_daily.y;	
			addChild(_greenborn);
			
			_bg=new CustomBitmap();
			_bg.source="liuyanbg";
			_bg.x=_titleBg.x-20;
			_bg.y=_daily.y+_daily.height ;
			_bg.width=_titleBg.width+50;
			_bg.height=300;
			addChild(_bg);
			
			_first=new TaskType();
			_first.x=_daily.x-10;
			_first.y=_daily.y+_daily.height ;
			_daily.binding=_first;
			addChild(_first);
			
			
			_second=new NewTaskType();
			_second.x=_first.x;
			_second.y=_first.y ;
			_second.visible=false;
			_greenborn.binding=_second;
			addChild(_second);
		
			this.addEventListener(MouseEvent.MOUSE_DOWN,act1_mc);
			this.addEventListener(MouseEvent.MOUSE_UP,act2_mc);

		}
		
		
		private function act1_mc(evt:MouseEvent):void
		{
			if(mouseX>150&&mouseX<400&&mouseY>-100&&mouseY<100)
			{
				this.startDrag();
			}
			
		}
		private function act2_mc(evt:MouseEvent):void
		{
			this.stopDrag();
		}
		
		
		private var _now:TabButton;
		
		private function liuyanclickHandler(e:MouseEvent):void
		{
			var btn:TabButton = e.target as TabButton;
			if(btn == _now) return;
			if(_now)_now.choose = false;
			btn.choose = true;
			_now = btn;
			
			switch(btn){
				case _titleBg:
					break;
				case _greenborn:
					break;
		
			}
		}
		
	}
}